//
//  AppDelegate.m
//  ProjectA_ManualGuest
//
//  Created by dingcong on 16/6/14.
//  Copyright © 2016年 丁聪. All rights reserved.
//

#import "AppDelegate.h"
#import "RootVCOfHomePage.h"
#import "RootVCOfTutorial.h"
#import "RootVCOfHandRing.h"
#import "RootVCOfFair.h"
#import "Masonry.h"
#import "UMSocial.h"
#import "UMSocialWechatHandler.h"
#import "UMSocialQQHandler.h"
#import "UMSocialSinaSSOHandler.h"
#import "VCOfMy.h"
@interface AppDelegate ()

@property(strong, nonatomic)UIImageView *Welcome;

@property(strong, nonatomic)UIView *nigView;
@end

@implementation AppDelegate

- (void)dealloc{
    
    [_Welcome release];
    [super dealloc];
    
}

- (instancetype)init{
    
    if (self = [super init])
    {
        NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
        [center addObserver:self selector:@selector(receiveNotifica:) name:@"heiyejianglin" object:nil];
        
        NSNotificationCenter *center2 = [NSNotificationCenter defaultCenter];
        [center2 addObserver:self selector:@selector(receiveNotifica2:) name:@"limingjianglin" object:nil];
        
    }
    return self;
    }
    
- (void)receiveNotifica:(NSNotification *)center
{
    self.nigView.hidden = NO;
//    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"value",@"key", nil];
//    [[NSNotificationCenter defaultCenter]postNotificationName:@"limingjianglinla" object:@"日" userInfo: dic];
}

- (void)receiveNotifica2:(NSNotification *)center
{
    self.nigView.hidden = YES;
//    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"value",@"key", nil];
//    [[NSNotificationCenter defaultCenter]postNotificationName:@"heiyejianglinla" object:@"黑夜" userInfo: dic];
}
    
    
    


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    
    
    
    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    
    

    
    
    

    RootVCOfHomePage *rvc1 = [[RootVCOfHomePage alloc]init];
    RootVCOfTutorial *rvc2 = [[RootVCOfTutorial alloc]init];
    RootVCOfHandRing *rvc3 = [[RootVCOfHandRing alloc]init];
    RootVCOfFair *rvc4 = [[RootVCOfFair alloc]init];
    VCOfMy *rvc5 = [[VCOfMy alloc]init];
    
    
    
    UINavigationController *navi1 = [[UINavigationController alloc]initWithRootViewController:rvc1];
    UINavigationController *navi2 = [[UINavigationController alloc]initWithRootViewController:rvc2];
    UINavigationController *navi3 = [[UINavigationController alloc]initWithRootViewController:rvc3];
    UINavigationController *navi4 = [[UINavigationController alloc]initWithRootViewController:rvc4];
    UINavigationController *navi5 = [[UINavigationController alloc]initWithRootViewController:rvc5];
    
    UITabBarController *tab = [[UITabBarController alloc]init];
    
    tab.viewControllers = @[navi1, navi2, navi3, navi4, navi5];
    
    
    
    self.window.rootViewController = tab;
    
    
    self.nigView = [[UIView alloc] initWithFrame:self.window.bounds];
    self.nigView.userInteractionEnabled = NO;
    self.nigView.hidden = YES;
    self.nigView.backgroundColor = [UIColor blackColor];
    self.nigView.alpha = 0.6;
    [self.window addSubview:self.nigView];
    [_nigView release];
//    self.Welcome = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
//   self.Welcome.image = [UIImage imageNamed:@"fugu.png"];
//    [self.window addSubview:self.Welcome];
//    [self.window bringSubviewToFront:_Welcome];
    
    
    
    
    
    [_window release];
    [navi1 release];
    [navi2 release];
    [navi3 release];
    [navi4 release];
    [navi5 release];
    [rvc1 release];
    [rvc2 release];
    [rvc3 release];
    [rvc4 release];
    [rvc5 release];
    
    [UMSocialData setAppKey:@"57709afd67e58ea3950004ef"];
    //设置友盟社会化组件appkey
   
    //设置微信AppId、appSecret，分享url
    [UMSocialWechatHandler setWXAppId:@"wxd930ea5d5a258f4f" appSecret:@"db426a9829e4b49a0dcac7b4162da6b6" url:@"http://www.umeng.com/social"];
    //设置手机QQ 的AppId，Appkey，和分享URL，需要#import "UMSocialQQHandler.h"
    [UMSocialQQHandler setQQWithAppId:@"100424468" appKey:@"c7394704798a158208a74ab60104f0ba" url:@"http://www.umeng.com/social"];
    //打开新浪微博的SSO开关，设置新浪微博回调地址，这里必须要和你在新浪微博后台设置的回调地址一致。需要 #import "UMSocialSinaSSOHandler.h"
    [UMSocialSinaSSOHandler openNewSinaSSOWithAppKey:@"3921700954"
                                              secret:@"04b48b094faeb16683c32669824ebdad"
                                         RedirectURL:@"http://sns.whalecloud.com/sina2/callback"];
    
    
    
    
//    [self performSelector:@selector(scale_1) withObject:nil afterDelay:0.0f];
//    [self performSelector:@selector(scale_2) withObject:nil afterDelay:0.5f];
//    [self performSelector:@selector(scale_3) withObject:nil afterDelay:1.0f];
//    [self performSelector:@selector(scale_4) withObject:nil afterDelay:1.5f];
//    [self performSelector:@selector(scale_5) withObject:nil afterDelay:2.0f];
//    [self performSelector:@selector(showWord) withObject:nil afterDelay:2.5f];

    return YES;
    
    
    
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    BOOL result = [UMSocialSnsService handleOpenURL:url];
    if (result == FALSE) {
        //调用其他SDK，例如支付宝SDK等
    }
    return result;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
